export function maskString(
  str,
  { length = 6, maskLen = 4, startLength, endLength, isPhone } = {}
) {
  if (typeof str !== "string" || !str.trim()) {
    return str;
  }

  let mask = "";
  for (let i = 0; i < maskLen; i++) {
    mask += "*";
  }

  if (isPhone) {
    startLength = 3;
    endLength = 4;
  } else {
    startLength = startLength ?? length;
    endLength = endLength ?? length;
  }

  let start = str.substring(0, startLength);
  let end = str.substring(str.length - endLength);
  return `${start}${mask}${end}`;
}
